
//
//  NewMonthBaogaoViewController.m
//  wangzhe
//
//  Created by 李 佳伟 on 2018/3/16.
//  Copyright © 2018年 李 佳伟. All rights reserved.
//

#import "NewMonthBaogaoViewController.h"
#import "JTCSM.h"
#import "NewMonthBaoGaoCollectionViewCell.h"
#import "NewMonthBaogaoInfoViewControllerViewController.h"
@interface NewMonthBaogaoViewController ()<UICollectionViewDelegate,UICollectionViewDataSource>

@property (nonatomic, strong) UICollectionView *collectionView;

@end

@implementation NewMonthBaogaoViewController

- (void)gotBack{
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.navigationController.navigationBar.hidden = NO;
    
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [df isRemoveTarbar:YES];
    self.navigationController.navigationBar.hidden = NO;
    self.view.backgroundColor =RGBACOLOR(241, 241, 241, 1);
    leftBarButtonItems_rightBarButtonItems *leftbtn = KCUSTOMNAVIGSTION_ALLOC;
    self.navigationItem.leftBarButtonItem = [leftbtn setBarButtonItemsImageName:@"fanhui.png" frame:KLeftBarButtonItemFrame_image target:self SEL:@selector(gotBack)];
    [self.view addSubview:self.collectionView];
}

- (UICollectionView *)collectionView {
    
    if (!_collectionView) {
        //minimumLineSpacing 设置最小行间距，minimumInteritemSpacing 设置同一列中间隔的cell最小间距。
        UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc]init];
        CGFloat  maxCol = 2;
        CGFloat margin = 20;
        CGFloat itemW   = (KCONTROLLERWith - (margin * (maxCol +1)))/maxCol;
         CGFloat itemH = 130;
        layout.itemSize = CGSizeMake(itemW, itemH);
        layout.minimumInteritemSpacing = margin;
        layout.minimumLineSpacing      = margin;
        layout.sectionInset = UIEdgeInsetsMake(10,margin,10, margin);
        _collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 0, self.view.LC_width, self.view.LC_height) collectionViewLayout:layout];
        
        _collectionView.delegate = self;
        _collectionView.dataSource = self;
        _collectionView.backgroundColor = [UIColor clearColor];
        [_collectionView registerClass:[NewMonthBaoGaoCollectionViewCell class] forCellWithReuseIdentifier:[NewMonthBaoGaoCollectionViewCell ReuseIdentifier]];
    }
    return _collectionView;
}

#pragma mark - 代理
#pragma mark - UICollectionViewDelegate

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    
    return 10;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    
    
    NewMonthBaoGaoCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:[NewMonthBaoGaoCollectionViewCell ReuseIdentifier] forIndexPath:indexPath];
    return cell;
    
}


- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
    
    NSLog(@"点我干什么啦!");
    NewMonthBaogaoInfoViewControllerViewController *vc = [[NewMonthBaogaoInfoViewControllerViewController alloc]init];
    [self.navigationController pushViewController:vc animated:YES];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
